USE [master]
GO

/****** Object:  Database [CheckDB]    Script Date: 12/8/2013 6:17:04 PM ******/
CREATE DATABASE [CheckDB]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'CheckDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\CheckDB.mdf' , SIZE = 4096KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'CheckDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\CheckDB_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [CheckDB] SET COMPATIBILITY_LEVEL = 110
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [CheckDB].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [CheckDB] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [CheckDB] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [CheckDB] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [CheckDB] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [CheckDB] SET ARITHABORT OFF 
GO

ALTER DATABASE [CheckDB] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [CheckDB] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [CheckDB] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [CheckDB] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [CheckDB] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [CheckDB] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [CheckDB] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [CheckDB] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [CheckDB] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [CheckDB] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [CheckDB] SET  DISABLE_BROKER 
GO

ALTER DATABASE [CheckDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [CheckDB] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [CheckDB] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [CheckDB] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [CheckDB] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [CheckDB] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [CheckDB] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [CheckDB] SET RECOVERY FULL 
GO

ALTER DATABASE [CheckDB] SET  MULTI_USER 
GO

ALTER DATABASE [CheckDB] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [CheckDB] SET DB_CHAINING OFF 
GO

ALTER DATABASE [CheckDB] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO

ALTER DATABASE [CheckDB] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO

ALTER DATABASE [CheckDB] SET  READ_WRITE 
GO


USE [CheckDB]
GO

/****** Object:  Table [dbo].[Bank]    Script Date: 12/8/2013 6:17:38 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Bank](
	[BankID] [int] IDENTITY(1,1) NOT NULL,
	[BankRNum] [char](9) NOT NULL,
	[BankName] [varchar](100) NOT NULL,
 CONSTRAINT [PK_Bank] PRIMARY KEY CLUSTERED 
(
	[BankID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


USE [CheckDB]
GO

/****** Object:  Table [dbo].[Account]    Script Date: 12/8/2013 6:24:41 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Account](
	[AcctID] [int] IDENTITY(1,1) NOT NULL,
	[AcctNumber] [varchar](17) NOT NULL,
	[AcctBankID] [int] NULL,
	[AcctFName] [varchar](30) NOT NULL,
	[AcctLName] [varchar](30) NOT NULL,
	[AcctDLNum] [varchar](15) NULL,
	[AcctPhoneNum] [varchar](22) NULL,
	[AcctCity] [varchar](50) NULL,
	[AcctAddr] [varchar](50) NULL,
	[AcctState] [varchar](2) NULL,
	[AcctZip] [varchar](10) NULL,
 CONSTRAINT [PK_AcctID] PRIMARY KEY CLUSTERED 
(
	[AcctID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Account]  WITH CHECK ADD  CONSTRAINT [FK_Account_Bank] FOREIGN KEY([AcctBankID])
REFERENCES [dbo].[Bank] ([BankID])
GO

ALTER TABLE [dbo].[Account] CHECK CONSTRAINT [FK_Account_Bank]
GO


USE [CheckDB]
GO

/****** Object:  Table [dbo].[User]    Script Date: 12/8/2013 6:25:21 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[User](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[UserFName] [varchar](30) NOT NULL,
	[UserLName] [varchar](30) NOT NULL,
	[UserUsername] [varchar](30) NOT NULL,
	[UserPassword] [varchar](30) NOT NULL,
	[UserAccessLevel] [char](2) NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


USE [CheckDB]
GO

/****** Object:  Table [dbo].[Check]    Script Date: 12/11/2013 9:28:45 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Check](
	[CheckID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NULL,
	[CheckDate] [date] NOT NULL,
	[CheckAmount] [money] NOT NULL,
	[CheckNumber] [varchar](15) NOT NULL,
	[CheckEntryDateTime] [datetime] NOT NULL,
	[CheckLetterSent] [int] NOT NULL,
	[CheckLetterReceived] [int] NOT NULL,
	[CheckCollected] [bit] NOT NULL,
	[CheckAcctID] [int] NOT NULL,
 CONSTRAINT [PK_Check] PRIMARY KEY CLUSTERED 
(
	[CheckID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Check] ADD  CONSTRAINT [DF_Check_CheckLetterSent]  DEFAULT ((0)) FOR [CheckLetterSent]
GO

ALTER TABLE [dbo].[Check] ADD  CONSTRAINT [DF_Check_CheckLetterReceived]  DEFAULT ((0)) FOR [CheckLetterReceived]
GO

ALTER TABLE [dbo].[Check]  WITH CHECK ADD  CONSTRAINT [FK_Check_Account] FOREIGN KEY([CheckAcctID])
REFERENCES [dbo].[Account] ([AcctID])
GO

ALTER TABLE [dbo].[Check] CHECK CONSTRAINT [FK_Check_Account]
GO

ALTER TABLE [dbo].[Check]  WITH CHECK ADD  CONSTRAINT [FK_User_Check] FOREIGN KEY([UserID])
REFERENCES [dbo].[User] ([UserID])
GO

ALTER TABLE [dbo].[Check] CHECK CONSTRAINT [FK_User_Check]
GO


